import java.util.Arrays;

public class Text {

    public static void main(String[] args) {

    }

    public static void main2(String[] args) {
        try{
            System.out.println(10/0);
            int[] arr = {1,2,3};   //发现异常后  try后面的代码不会执行  所以没打印数组下标越界异常
            arr[10] = 0;
            System.out.println(Arrays.toString(arr));
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("数组下标越界");
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("算数异常");
        }catch(Exception e){   //父类异常要写在子类后  否则会编译错误
            System.out.println("e");
        } finally {
            System.out.println("finally");
        }
    }

    public static void main1(String[] args) {

        int[] a = {1,2,3};
        int index = 3;
        if(a == null){
            throw new NullPointerException();
        }
        if(index < 0) {
            throw new ArrayIndexOutOfBoundsException("数组下标越界");
        }
        System.out.println("hhhhh");

        try{
            System.out.println(10/0);
            int[] arr = {1,2,3};   //发现异常后  try后面的代码不会执行  所以没打印数组下标越界异常
            arr[10] = 0;

        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("数组下标越界");
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("算数异常");
        }finally {
            System.out.println("finally");
        }



    }
}
